package com.tanhua.server.controller;

import com.tanhua.model.dto.TestsoulAnswersDto;
import com.tanhua.model.vo.TestSoulPaperVo;
import com.tanhua.model.vo.TestSoulReportVo;
import com.tanhua.server.service.TestSoulService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2021/11/9 23:34
 */

@RestController
@RequestMapping("testSoul")
public class TestSoulController {

    @Autowired
    private TestSoulService testSoulService;

    @GetMapping
    public ResponseEntity paperList() {
        List<TestSoulPaperVo> voList = testSoulService.paperList();
        return ResponseEntity.ok(voList);
    }

    @PostMapping
    public ResponseEntity testSoul(@RequestBody Map<String,List<TestsoulAnswersDto>> answers) {
        String reportId = testSoulService.testSoul(answers);
        return ResponseEntity.ok(reportId);
    }

    @GetMapping("report/{id}")
    public ResponseEntity report(@PathVariable("id") String id) {
        TestSoulReportVo reportVo = testSoulService.report(id);
        return ResponseEntity.ok(reportVo);
    }
}
